using Dialog.Data;
using System.Collections.Generic;
using UnityEngine;


public class SetBackgroundCommand : IDialogueCommand
{
    public string bg;

    public SetBackgroundCommand(string bg)
    {
        this.bg = bg;
    }

    public void Execute(DialogueRuntime runtime)
    {
        runtime.ui.SetBackground(bg);
        runtime.Continue();
    }
}


public class SetBGMCommand : IDialogueCommand
{
    public string bgm;

    public SetBGMCommand(string bgm)
    {
        this.bgm = bgm;
    }

    public void Execute(DialogueRuntime runtime)
    {
        runtime.ui.PlayBGM(bgm);
        runtime.Continue();
    }
}


public class SetTitleCommand : IDialogueCommand
{
    public string title;

    public SetTitleCommand(string title)
    {
        this.title = title;
    }

    public void Execute(DialogueRuntime runtime)
    {
        runtime.ui.ShowTitle(title);
        runtime.Continue();
    }
}


public class SayCommand : IDialogueCommand
{
    string role;
    string portrait;
    string position;
    string text;

    public SayCommand(string role, string portrait, string position, string text)
    {
        this.role = role;
        this.portrait = portrait;
        this.position = position;
        this.text = text;
    }

    public void Execute(DialogueRuntime runtime)
    {
        runtime.ui.ShowDialogue(role, portrait, position, text);
    }
}


public class JumpCommand : IDialogueCommand
{
    string target;

    public JumpCommand(string target)
    {
        this.target = target;
    }

    public void Execute(DialogueRuntime runtime)
    {
        if (target == "end")
        {
            runtime.EndDialogue();
            return;
        }

        runtime.StartDialogue(int.Parse(target));
    }
}


public class ChoiceCommand : IDialogueCommand
{
    public List<ChoiceItem> choices;

    public ChoiceCommand(List<ChoiceItem> choices)
    {
        this.choices = choices;
    }

    public void Execute(DialogueRuntime runtime)
    {
        runtime.ui.ShowChoices(choices, index =>
        {
            runtime.StartDialogue(choices[index].targetBlock);
        });
    }
}


public class FadeCommand : IDialogueCommand
{
    public void Execute(DialogueRuntime runtime)
    {
        runtime.ui.FadeScreen();
        runtime.Continue();
    }
}

